<?php
/*********************************************
  CPG Dragonfly™ CMS
  ********************************************
  Copyright © 2004 - 2007 by CPG-Nuke Dev Team
  http://dragonflycms.org

  Dragonfly is released under the terms and conditions
  of the GNU GPL version 2 or any later version
**********************************************/
if (!defined('CPG_NUKE')) { exit; }

if (isset($_GET['sid'])) {
	$sid = intval($_GET['sid']);
	$result = $db->query("SELECT s.title, s.ptime, s.hometext, s.bodytext, s.informant, s.notes
	FROM {$db->TBL->stories} s
	LEFT JOIN {$db->TBL->topics} t ON (t.topicid = s.topic)
	WHERE s.sid='$sid' AND s.ptime<=".time());
	if ($result->num_rows < 1) { URL::redirect(URL::index()); }
	list($title, $time, $hometext, $bodytext, $author, $notes) = $result->fetch_row();
	$result->free();

	require_once('includes/nbbcode.php');
	$hometext = BBCode::decodeAll($hometext, 1, true);
	$bodytext = BBCode::decodeAll($bodytext, 1, true);
	$notes = BBCode::decodeAll($notes, 1, true);
	echo '
	<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
	"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
	<html dir="'._TEXT_DIR.'" lang="'._LANGCODE.'">
	<head>
	 <base href="'.$BASEHREF.'" />
	 <meta http-equiv="Content-Type" content="text/html; charset='._CHARSET.'" />
	 <title>'.$MAIN_CFG->global->sitename.' '._BC_DELIM.' '.$title.'</title>
	 <link rel="stylesheet" href="themes/'.$CPG_SESS['theme'].'/style/style.css" type="text/css" media="screen" />
	 <link rel="stylesheet" href="includes/css/print.css" type="text/css" media="print" />
	 <style type="text/css">
<!--
.holder {
	text-indent: 20px;
	border: thin solid #000000;
	padding-right: 20px;
	padding-left: 20px;
	width: 600px;
	color: #000000;
	background: #FFFFFF;
}
-->
     </style>
	</head>
	<body>
	<table style="margin:auto;" class="holder">
  <tr>
    <td>
	<p style="text-align:center;">
	<strong>'.$title.'</strong><br />
	'.Dragonfly::getKernel()->L10N->date('DATE_F', $time).'<br /><br />'.
	_POSTEDBY.' '.$author.'
	</p>
	<p align="left">
	'.$hometext.'<br /><br />
	'. $bodytext.'</p>';
	if ($notes != '') {
		echo '<br /><br /><b>Notes:</b> '.$notes;
	}
	echo '</td>
  </tr>
</table>
	<p style="text-align:center;">
	Content received from: '.$MAIN_CFG->global->sitename.', '.BASEHREF.'
	</p></body>
	</html>';
} else {
	URL::redirect(URL::index());
}
